package com.pinkpig.excel;

import com.pinkpig.excel.metadata.DatabaseTableParser;
import com.pinkpig.excel.xml.TableExportConfigurationParser;
import com.pinkpig.excel.xml.config.TableExportConfiguration;
import org.xml.sax.SAXException;

import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.net.URL;
import java.sql.SQLException;


/**
 * @author vincenfeng
 */
public class TableExport {

    private static String exportFilePatch = "./src/test/resources/";

    public void export(URL configPath, String fileName) throws SQLException, IOException, SAXException, ParserConfigurationException {
        System.out.println("开始导出...");
        TableExportConfiguration configuration = new TableExportConfigurationParser().parse(configPath);
        DatabaseTableParser databaseTableParser = new DatabaseTableParser(configuration);
        databaseTableParser.parse();
        new TableExportDelegate(configuration, databaseTableParser, exportFilePatch+fileName+".xlsx").generateExcel();
        System.out.println("导出完成...");
    }

}
